package com.jr.controller;


import com.jr.entry.Enterprise;
import com.jr.entry.Resume;
import com.jr.pojo.EnterprisewithPost;
import com.jr.service.EnterpriseService;
import com.jr.util.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/Enterprise/")
public class EnterpriseController {

    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    private ResultObject resultObject;


    /*查询公司详情,100成功，101失败*/
    @RequestMapping("selectEnterprise")
    public ResultObject selectEnterprise(EnterprisewithPost enterprisewithPost){
        ArrayList<EnterprisewithPost> enterprisewithPosts = enterpriseService.postShow(enterprisewithPost);
        if (enterprisewithPosts.size()!=0){
            resultObject.setStatus(100);
            resultObject.setResult(enterprisewithPosts);
            System.out.println("查询的结果是"+enterprisewithPosts);
        }else{
            resultObject.setStatus(101);
        }
        System.out.println("返回的结果"+resultObject.getResult());
        return resultObject;
    }

    /*
    * 查询该账号下存不存在简历
    * 100成功，101失败
    * */
    @RequestMapping("selectResume")
    public ResultObject selectResume(Resume resume){
        ArrayList<Resume> resumes = enterpriseService.selectResume(resume);
        System.out.println("resume is" + resume);
        if (resumes.size()!=0){
            resultObject.setStatus(100);
            resultObject.setResult(1);
        }else{
            resultObject.setStatus(101);
            resultObject.setResult(2);
        }
        return resultObject;
    }
}
